package com.br.estoque.model.dao;


import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Collection;
import com.br.estoque.model.vo.Material;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;

public class OperacaoDAO extends AbstractDAO<Material>{
	private static final String 	SQL_INSERT = "INSERT INTO controle(numeroPatrominal,tipoMaterial,modelo,marca,observacao,localizacao) VALUES(?,?,?,?,?,?);";
  //private static final String SQL_UPDATE = "";
	
	
	@Override
	public int criar(Material obj) {
		try {
			
			Class.forName(DRIVER);
			Connection conn = (Connection) DriverManager.getConnection(URL, USER, PASSWORD);
			PreparedStatement stmt = (PreparedStatement) conn.prepareStatement(SQL_INSERT);
			
			stmt.setInt(1, obj.getNumeroPatrimonial());
			stmt.setString(2, obj.getTipoMaterial());
			stmt.setString(3, obj.getModelo());
			stmt.setString(4, obj.getMarca());
			stmt.setString(5, obj.getObservacao());
			stmt.setString(6, obj.getLocalizacao());
			
			System.out.println("Estado da conexão "+stmt.isClosed());
			System.out.println("Resultado da Query "+SQL_INSERT);
			stmt.executeUpdate();
		
		} catch (ClassNotFoundException e) {
		
			System.out.println("Classe não econtrada, mensagem :\n"+e.getMessage());
			e.printStackTrace();
		
		} catch (SQLException e) {
		
			System.out.println("Erro de execução de query, mensagem \n"+e.getMessage());
			e.printStackTrace();
		
		}
		
		return 0;
	}

	@Override
	public int alterar(Material obj) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int excluir(Material obj) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Collection<Material> buscar() {
		// TODO Auto-generated method stub
		return null;
	}
	
}
